program walk
	integer :: i, j, total
	real :: m_freq(20)
	integer :: result(10000)
	real, parameter :: p=0.3
	real :: rand
	integer :: seed(12)
	real :: mean, sd, sum

	call system_clock(seed(1))
	call random_seed(put=seed)

	!generating the result array containg the result of evry one the 10000 experiments
	
	do j=1,10000
		result(j)=0
		do i=1,20
			call random_number(rand)
			if(rand<=0.3)	then
				result(j)=result(j)+1
			end if
		end do
	end do
	!initializinfg the freq array
	do i=1,20
		m_freq(i)=0
	end do
	! calcualting the freq of m
	do i=1,10000
		m_freq(result(i)) = m_freq(result(i))+1
		
	end do
		
	sum = 0
	do i = 1, 20
		sum = sum + m_freq(i)
	end do
	do i = 1, 20
		m_freq(i) = real(m_freq(i))/sum
		print *, m_freq(i)
	end do
	mean=0
	do i=1,20
		mean = mean + real(i)*m_freq(i)
	end do

	sum = 0
	do i = 1, 20
		sum = sum + (real(i)**2) * m_freq(i)
	end do
	sd = sqrt(sum - mean**2)

	print *,"mean=",mean
	print *,"sd=",sd
	
end program